home *** CD-ROM | disk | FTP | other *** search
/ Hot Super Models / Hot Super Models.iso / dos / tif / fnsplit.c < prev    next >
C/C++ Source or Header  |  1992-07-05  |  1KB  |  68 lines

  1. #include <strings.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. void
  6. fnsplit (char *path, char *drive, char *dir, char *name, char *ext)
  7. {
  8.   char temppath[128];
  9.   char *cptr, *p1, *p2, *p3;
  10.  
  11.   *(ext++) = '.';
  12.  
  13.   strcpy (temppath, path);
  14.   cptr = strtok (temppath, " :");
  15.   p1 = strtok (NULL, ":");
  16.   if (p1 == NULL)
  17.     {
  18.       *drive = '\0';
  19.       p1 = temppath;
  20.     }
  21.   else
  22.     {
  23.       *drive = *cptr;
  24.       *(drive + 1) = ':';
  25.     }
  26.   strcpy (temppath, path);
  27.   p2 = p1;
  28.   p3 = p1;
  29.   while (*p2 != '\0')
  30.     {
  31.       if (*p2 == '\\')
  32.     p3 = p2;
  33.       p2++;
  34.     }
  35.   p2 = p1;
  36.   while (p2 != p3)
  37.     *(dir++) = *(p2++);
  38.   if (p2 != p1)
  39.     {
  40.       *(dir++) = '\\';
  41.       p3++;
  42.     }
  43.   *dir = '\0';
  44.   while ((*p3) != '.' && (*p3) != '\0')
  45.     *(name++) = *(p3++);
  46.   *name = '\0';
  47.   if (*(p3++) == '.')
  48.     while (*p3 != NULL)
  49.       *(ext++) = *(p3++);
  50.   *ext = '\0';
  51. }
  52. /*
  53. main(int argc,char **argv)
  54. {
  55.     char hell[100];
  56.     char drive[10];
  57.     char dir[50];
  58.     char name[50];
  59.     char ext[10];
  60.  
  61.     fnsplit(argv[1],drive,dir,name,ext);
  62.     printf("%s %s %s %s\n",drive,dir,name,ext);
  63. }
  64.  
  65.  
  66.  
  67.   */
  68.